<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@ include file="/pub/includ.jsp"%>
<script type="text/javascript">


     $(document).ready(function(){
	        $.formValidator.initConfig({formid:"productsform",alertmessage:false,onerror:function(msg){alert(msg)}});
	        $("#product_name").formValidator({}).inputValidator({min:1,max:64,onerror:"产品名称不能为空且不能过长，请确认"});
		
	        $("#product_code").formValidator({}).inputValidator({min:1,max:64,onerror:"编码不能为空且不能超过64个字符哦"});
			$("#price").formValidator({empty:"true"}).inputValidator({min:1,max:10,onerror:"产品价格过长，请确认"});
			$("#keyword").formValidator({empty:"true"}).inputValidator({min:1,max:60,onerror:"关键字过长，请确认"});
			$("#inventory").formValidator({empty:"true"}).inputValidator({min:1,max:10,onerror:"库存过长，请确认"});
			$("#picpath").formValidator({empty:"true"}).inputValidator({min:1,max:125,onerror:"展示图片过长，请确认"});
			$("#introduction").formValidator({empty:"true"}).inputValidator({min:1,max:60,onerror:"产品介绍过长，请确认"});
			$("#promotion").formValidator({empty:"true"}).inputValidator({min:1,max:60,onerror:"促销信息过长，请确认"});
			});
	  var save = function(){
			var flag = "failure";
			if($.formValidator.pageIsValid()){
				var options = {
					type: 'POST',
					async: false,
					dataType: 'content-type',
					success: function(msg) {
						flag = msg;
					}
				}
				$('#productsform').ajaxSubmit(options);
			}
			return flag;
		}
	function selectImage(){
		opendailog("{src:'<%=path %>/res/get/selectImageIndex?type=p',title:'选取图片',width:600,height:400,savefunc:'savefunc2'}",window);
	}
	function savefunc2(frame){
		var retv = frame.contentWindow.save();
		if(retv){
			$('#small_picpath').val(retv);
			return "success";		
		}
	}
</script>
<form id="productsform"  action="<%=path%>/ext/products/save" method="post" target="_self">
<table><tr><td height="2px"></td></tr></table>
<table align="center" border="0" cellpadding="0" cellspacing="1" class="table_nbw" >
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">产品名称</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="product_name" name="product_name" value="${products.product_name}"></td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">产品编码</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="product_code" name="product_code" value="${products.product_code}"></td>
	</tr>	
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">价格</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="price" name="price" value="${products.price}"></td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">应用状态</td>
		<td align="left" style="background-color:fff">&nbsp;
			<select  name="valid_flag" style="width:80" >
				<option value="0" ${'0'==products.valid_flag?'selected':''}>启用</option>
				<option value="1" ${'1'==products.valid_flag?'selected':''}>禁用</option>
			</select>
		</td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">关键词</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="keyword" name="keyword" value="${products.keyword}"></td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">库存</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="inventory" name="inventory" value="${products.inventory}"></td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">展示图片</td>
		<td align="left" style="background-color:fff">&nbsp;<input class="textfiled_nbw"  type="text" id="small_picpath" name="small_picpath" value="${products.small_picpath}">
			<input type = "button"  value = "选择"  onclick = "selectImage();">
		</td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">产品介绍</td>
		<td align="left" style="background-color:fff">&nbsp;<textarea rows="4" cols="40" class="textfiled_nbw"  type="text" id="introduction" name="introduction" >${products.introduction}</textarea></td>
	</tr>
	<tr >
		<td align="right" width="30%"  style="background-color:fff;height:25px;">促销信息</td>
		<td align="left" style="background-color:fff">&nbsp;<textarea rows="4" cols="40" class="textfiled_nbw"  type="text" id="promotion" name="promotion" >${products.promotion}</textarea></td>
	</tr>
</table>


<input type=hidden name="id" id="product_id" value="${products.id}" />
<input type=hidden name="groupid" value="${products.groupid}" />
<input type=hidden name="site_id" value="${SiteId}" />
<input type=hidden name="create_user" value="${UserId}" />
</form>


